package com.zhanbo.zhanbowymusic.main.featured.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import com.mwx.baselib.bean.HomeBannerBean;
import com.mwx.baselib.utils.GlideUtils;
import com.youth.banner.adapter.BannerAdapter;
import com.zhanbo.zhanbowymusic.R;

import java.util.List;

public class HomeFeaturedBannerAdapter extends BannerAdapter<HomeBannerBean, HomeFeaturedBannerAdapter.BannerViewHolder> {
    private Context context;
    public HomeFeaturedBannerAdapter(Context context, List<HomeBannerBean> mDatas) {
        //设置数据，也可以调用banner提供的方法,或者自己在adapter中实现
        super(mDatas);
        this.context =context;
    }

    //创建ViewHolder，可以用viewType这个字段来区分不同的ViewHolder
    @Override
    public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_featured_banner,parent,false);

        return new BannerViewHolder(view);
    }

    @Override
    public void onBindView(BannerViewHolder holder, HomeBannerBean data, int position, int size) {
//        GlideUtils.loadImageRounded(context,data,holder.imageView);
        GlideUtils.loadImage(context,data.getImage(),holder.imageView);
    }
    class BannerViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;

        public BannerViewHolder(@NonNull View view) {
            super(view);
            this.imageView = view.findViewById(R.id.iv_banner);
        }
    }
}
